﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import flash.events.*;
    import flash.geom.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;

    public class AbstractViewMediator extends RenderListMediator {

		[Inject]
        public var userModel:UserModel;
        protected var m_mouseState:String;

        private function get view():AbstractView{
            return ((viewComponent as AbstractView));
        }
        override public function onRegister():void{
            super.onRegister();
            this.m_mouseState = MouseEvent.MOUSE_OUT;
            eventMap.mapListener(eventDispatcher, EventConstants.SET_TO_POSITION, this.onSetToPosition);
            eventMap.mapListener(eventDispatcher, EventConstants.HIDE_VIEW, this.onHideDisplay);
            eventMap.mapListener(eventDispatcher, EventConstants.SHOW_VIEW, this.onShowDisplay);
            eventMap.mapListener(eventDispatcher, EventConstants.DISABLE_VIEW, this.disableView);
            eventMap.mapListener(eventDispatcher, EventConstants.ENABLE_VIEW, this.enabledView);
            if (this.userModel.isVisitFriendsMode()){
                this.view.setDisabled();
            };
        }
        private function enabledView(_arg1:InfoEvent):void{
            if ((((_arg1.id == null)) || ((_arg1.id == this.id)))){
                this.view.setEnabled();
            };
        }
        private function disableView(_arg1:InfoEvent):void{
            if ((((_arg1.id == null)) || ((_arg1.id == this.id)))){
                this.view.setDisabled();
            };
        }
        protected function onSetToPosition(_arg1:InfoEvent):void{
            var _local2:Point;
            if (this.id == _arg1.id){
                _local2 = Point(_arg1.info);
                this.setPosition(_local2.x, _local2.y);
            };
        }
        protected function setPosition(_arg1:Number, _arg2:Number):void{
            this.view.x = _arg1;
            this.view.y = _arg2;
            updateRenderList();
        }
        public function get id():String{
            return ((this.view) ? this.view.id : null);
        }
        private function onShowDisplay(_arg1:InfoEvent):void{
            if (this.id == _arg1.id){
                this.showView();
            };
        }
        private function onHideDisplay(_arg1:InfoEvent):void{
            if (this.id == _arg1.id){
                this.hideView();
            };
        }
        protected function showView():void{
            this.view.show();
        }
        protected function hideView():void{
            this.view.hide();
        }
        override public function preRemove():void{
            this.view.remove();
            super.preRemove();
        }
        override public function onRemove():void{
        }

    }
}//package net.wooga.pets.views 
